using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace servermon_library
{
	public class ServerButton : UserControl
	{
		public String text; // text shown in the button
		public Int32 id;
		public Color backgroundColor;
		public String server_ip;
		private Color originalColor;

		protected override void OnPaint(PaintEventArgs e)
		{
			// our drawing tools
			Graphics graphics = e.Graphics;
			Pen pen = new Pen(Color.Black, 1);
			SolidBrush brush = new SolidBrush(backgroundColor);
			SolidBrush textbrush = new SolidBrush(Color.Black);
			Font font = new Font("Arial", 7);
			//width and height are inherited from the UserControl class
			Width = 45;
			Height = 60;
			this.DoubleBuffered = true;

			// draw a nice looking icon
			graphics.FillRectangle(brush, 0, 0, 40, 50);
			graphics.DrawRectangle(pen, 5, 5, 5, 6);
			graphics.DrawRectangle(pen, 13, 5, 5, 6);
			graphics.DrawRectangle(pen, 21, 5, 5, 6);
			graphics.DrawRectangle(pen, 29, 5, 5, 6);
			graphics.DrawRectangle(pen, 5, 15, 5, 6);
			graphics.DrawRectangle(pen, 13, 15, 5, 6);
			graphics.DrawRectangle(pen, 21, 15, 5, 6);
			graphics.DrawRectangle(pen, 29, 15, 5, 6);
			graphics.DrawLine(pen, new Point(3, 45), new Point(36, 45));
			graphics.DrawString(text, font, textbrush, new PointF(1, 50));
		}

		protected override void OnMouseEnter(EventArgs e)
		{
			originalColor = backgroundColor;
			backgroundColor = Color.Thistle;
			this.Invalidate();
		}

		protected override void OnMouseLeave(EventArgs e)
		{
			backgroundColor = originalColor;
			this.Invalidate();
		}
		public ServerButton(String _text, Int32 _id, Color color, String ip)
		{
			text = _text;
			id = _id;
			backgroundColor = color;
			server_ip = ip;
		}
		public ServerButton()
		{
			text = "undefined";
			id = 0;
			backgroundColor = Color.Gray;
			server_ip = "0.0.0.0";
		}
	}
}
